home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / LHiResPrintout / LHiResCaption.cp next >
Encoding:
Text File  |  1997-06-30  |  3.0 KB  |  122 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    LHiResCaption.cp                   
  3. //  Dan Crevier <mailto:Dan.Crevier@pobox.com>
  4. //  A subclass of LCaption that changes the text size proportionally if it is
  5. //  enclosed in an LHiResPrinter. See LHiResPrintout for detials
  6.  
  7. #ifdef PowerPlant_PCH
  8. #include PowerPlant_PCH
  9. #endif
  10.  
  11. #include "LHiResCaption.h"
  12. #include <LCaption.h>
  13. #include <LStream.h>
  14. #include <UDrawingUtils.h>
  15. #include <UTextTraits.h>
  16. #include "LHiResPrintout.h"
  17.  
  18. #ifndef __TEXTUTILS__
  19. #include <TextUtils.h>
  20. #endif
  21.  
  22. // ---------------------------------------------------------------------------
  23. //        • LHiResCaption
  24. // ---------------------------------------------------------------------------
  25. //    Default Constructor
  26.  
  27. LHiResCaption::LHiResCaption()
  28. {
  29. }
  30.  
  31.  
  32. // ---------------------------------------------------------------------------
  33. //        • LHiResCaption(const LHiResCaption&)
  34. // ---------------------------------------------------------------------------
  35. //    Copy Constructor
  36.  
  37. LHiResCaption::LHiResCaption(
  38.     const LHiResCaption    &inOriginal)
  39.         : LCaption(inOriginal)
  40. {
  41. }
  42.  
  43.  
  44. // ---------------------------------------------------------------------------
  45. //        • LHiResCaption(SPaneInfo&, Str255, ResIDT)
  46. // ---------------------------------------------------------------------------
  47. //    Construct from parameters. Use this constructor to create a Caption
  48. //    from runtime data.
  49.  
  50. LHiResCaption::LHiResCaption(
  51.     const SPaneInfo    &inPaneInfo,
  52.     ConstStringPtr    inString,
  53.     ResIDT            inTextTraitsID)
  54.         : LCaption(inPaneInfo, inString, inTextTraitsID)
  55. {
  56. }    
  57.  
  58.  
  59. // ---------------------------------------------------------------------------
  60. //        • LHiResCaption(LStream*)
  61. // ---------------------------------------------------------------------------
  62. //    Construct from data in a Stream
  63.  
  64. LHiResCaption::LHiResCaption(
  65.     LStream    *inStream)
  66.         : LCaption(inStream)
  67. {
  68. }
  69.  
  70.  
  71. // ---------------------------------------------------------------------------
  72. //        • ~LHiResCaption
  73. // ---------------------------------------------------------------------------
  74. //    Destructor
  75.  
  76. LHiResCaption::~LHiResCaption()
  77. {
  78. }
  79.  
  80.  
  81.  
  82.  
  83. // ---------------------------------------------------------------------------
  84. //        • DrawSelf
  85. // ---------------------------------------------------------------------------
  86. //    Draw the Caption
  87.  
  88. void
  89. LHiResCaption::DrawSelf()
  90. {
  91.     Rect    frame;
  92.     
  93.     CalcLocalFrameRect(frame);
  94.     
  95.     Int16    just = UTextTraits::SetPortTextTraits(mTxtrID);
  96.     
  97.     RGBColor    textColor;
  98.     ::GetForeColor(&textColor);
  99.     
  100.     ApplyForeAndBackColors();
  101.     ::RGBForeColor(&textColor);
  102.     
  103.     // look for LHiResPrintout as superview
  104.     LView *super = GetSuperView();
  105.     while(super != NULL)
  106.     {
  107.         LHiResPrintout *superPrintout = dynamic_cast<LHiResPrintout *>(super);
  108.         // if it's a LHiResPrintout, resize the text
  109.         if (superPrintout != NULL)
  110.         {
  111.             GrafPtr thePort;
  112.             ::GetPort(&thePort);
  113.             ::TextSize(thePort->txSize * superPrintout->GetResolution()/72);
  114.             break;
  115.         }
  116.         super = super->GetSuperView();
  117.     }
  118.     
  119.     UTextDrawing::DrawWithJustification((Ptr)&mText[1], mText[0],
  120.                         frame, just, true);
  121. }
  122.